package month4.day26;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Scanner;

public class S1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("输入日期");
        String riqi = in.next();
        SimpleDateFormat[] df = new SimpleDateFormat[3];
        df[0] = new SimpleDateFormat("yyyy/MM/dd");
        df[1] = new SimpleDateFormat("yyyyMMdd");
        df[2] = new SimpleDateFormat("yyyy-MM-dd");
        int i = 0;
        for (; i < df.length; ) {
            df[i].setLenient(false);
            try {
                System.out.println(df[i].parse(riqi));
                break;
            } catch (ParseException e) {
                i++;
            }
        }
        if (i == 3)
            System.out.println("日期格式非法");



//        try {
//            df1.setLenient(false);
//            System.out.println(df1.parse(riqi));
//        } catch (ParseException e1) {
//            try {
//                df2.setLenient(false);
//                System.out.println(df2.parse(riqi));
//
//            } catch (ParseException e2) {
//                try {
//                    df3.setLenient(false);
//                    System.out.println(df3.parse(riqi));
//                } catch (ParseException e3) {
//                    System.out.println("日期非法");
//                }
//            }
//        }


    }
}
